package znet

import (
	"fmt"
	"zinx/ziface"
)

type PingRouter struct {
	BaseRouter
}

func (this *PingRouter) PreHandle(request ziface.IRequest) {
	fmt.Println("call Router prehandle")
	_,err := request.GetConnection().GetTCPConnection().Write([]byte("before ping\n"))
	if err != nil {
		fmt.Println("callback ping error")
	}
}

func (this *PingRouter) Handle(request ziface.IRequest) {
	fmt.Println("call pingrouter handle")
	_,err := request.GetConnection().GetTCPConnection().Write([]byte("ping ping ping\n"))
	if err != nil {
		fmt.Println("callback ping error")
	}
}

func (this *PingRouter) PostHandle(request ziface.IRequest) {
	fmt.Println("call Router PostHandle")
	_,err := request.GetConnection().GetTCPConnection().Write([]byte("After ping\n"))
	if err != nil {
		fmt.Println("call back ping ping ping error")
	}
}

